<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
?>
<div class="book-slider left">
   <div id="da-slider" class="da-slider">
   	<?php 
      if(count($list_new_product) > 0){
         $i = 0;                  
         foreach($list_new_product as $item){
            $i++;
            if($i == 4) break;                                   
            $link = $model->linkDetail($item->book_id,$item->book_name);
            ?>
            <div class="da-slide">
         		<div class="da-img"><img style="width: 135px;" src="<?php echo Yii::app()->request->baseUrl?>/uploads/pictures/product/thumb_<?php echo $item->book_image?>"/></div>
               <h2 class="usu-color"><?php echo $item->book_name?></h2>
               <?php 
                  $pub_name = isset($item->getRelated('publisher')->pub_name) ? $item->getRelated('publisher')->pub_name : 'Đang cập nhật';
               ?>
               <p class="publisher">Nhà xuất bản: <?php echo $pub_name?></p>
               <?php 
                  $new_price = $item->book_price  - round($item->book_price * ($item->book_sale/100),0);
               ?>
         		<p class="book-price" class="price"><?php echo Str::formatNumber($new_price)?> đ</p>
               <a class="da-link" href="<?php echo $link?>">Chi tiết</a>            
         	</div>
         <?php }?>
      <?php }?>
   	<nav class="da-arrows">
   		<span class="da-arrows-prev sprite absolute"></span>
   		<span class="da-arrows-next sprite absolute"></span>
   	</nav>
   </div>
</div>
<div class="widget-box right text-center">
   <div id="text-2" class="visible-all-devices "> 
      <div class="textwidget">
         <a href="<?php echo Yii::app()->request->baseUrl;?>/discount">
         <div class="banner-round">
            <span class="text11"><?php echo isset($max_of_discount->book_sale) ? $max_of_discount->book_sale : '30'?>%</span>
            <span class="text12">off</span>
         </div>
         <div class="clear"></div>
         <span class="text13">Siêu giảm giá</span>
         <div class="clear"></div>
         <span class="text14">Xem</span>
         </a>
      </div>
   </div>
</div>
<div class="clear"></div>
<div class="left-content left">
<div class="featured-box">
   <h3 class="title">Sách hay</h3>
   <div class="woocommerce">
      <ul class="list-products">
         <?php if(count($list_special_product) > 0){
            foreach($list_special_product as $item){
               $link = $model->linkDetail($item->book_id,$item->book_name);
               ?>
               <li class="product-item relative">
                  <a href="<?php echo $link?>">
                     <div class="left">
                        <img alt="<?php echo $item->book_name?>" src="<?php echo Yii::app()->request->baseUrl?>/uploads/pictures/product/<?php echo $item->book_image?>" />
                     </div>
                     <div class="info">
                        <h3 class="font-14"><?php echo $item->book_name?></h3>
                        <p class="num-page">Số trang: <?php echo Str::formatNumber($item->book_num_page)?></p>
                        <?php 
                           $pub_name = isset($item->getRelated('publisher')->pub_name) ? $item->getRelated('publisher')->pub_name : 'Đang cập nhật';
                        ?>
                        <p class="publisher">Nhà xuất bản: <?php echo $pub_name?></p>
                        <p class="price">Giá: <?php echo Str::formatNumber($item->book_price)?> đ</p>
                     </div>
                  </a>
                  <div class="option absolute">
                     <p class="btn btn-info add-to-cart" onclick="adToCart(<?php echo $item->book_id?>)">Thêm vào giỏ hàng</p>
                  </div>
               </li>
            <?php }
          }?>
      </ul>
   </div>
</div>
<div class="new-box">
   <h3 class="title">Sách mới</h3>
   <div class="woocommerce">
      <ul class="list-products">
         <?php if(count($list_new_product) > 0){
            foreach($list_new_product as $item){
               $link = $model->linkDetail($item->book_id,$item->book_name);
               ?>
               <li class="product-item relative">
                  <a href="<?php echo $link?>">
                     <div class="left relative">
                        <?php if($item->book_sale > 0){?>
                        <div class="sale absolute">
                           <?php echo '-'.$item->book_sale.'%'?>
                        </div>
                        <?php }?>
                        <img alt="<?php echo $item->book_name?>" src="<?php echo Yii::app()->request->baseUrl?>/uploads/pictures/product/thumb_<?php echo $item->book_image?>" />
                     </div>
                     <div class="info">
                        <h3 class="font-14"><?php echo $item->book_name?></h3>
                        <p class="num-page">Số trang: <?php echo Str::formatNumber($item->book_num_page)?></p>
                        <?php 
                           $pub_name = isset($item->getRelated('publisher')->pub_name) ? $item->getRelated('publisher')->pub_name : 'Đang cập nhật';
                        ?>
                        <p class="publisher">Nhà xuất bản: <?php echo $pub_name?></p>
                        <?php 
                           $new_price = $item->book_price  - round($item->book_price * ($item->book_sale/100),0);
                        ?>
                        <p class="price"><?php echo Str::formatNumber($new_price)?> đ</p>
                        <?php if($item->book_sale > 0){?>
                        <p class="old-price"><?php echo Str::formatNumber($item->book_price)?> đ</p>
                        <?php }?>
                     </div>
                  </a>
                  <div class="option absolute">
                     <p class="btn btn-info add-to-cart" onclick="adToCart(<?php echo $item->book_id?>)">Thêm vào giỏ hàng</p>
                  </div>
               </li>
            <?php }
          }?>
      </ul>
   </div>
</div>
<?php if(count($list_publish_product) > 0){?>
   <div class="new-box">
      <h3 class="title">Sách sắp phát hành</h3>
      <div class="woocommerce">
         <ul class="list-products">
            <?php
               foreach($list_publish_product as $item){
                  $link = $model->linkDetail($item->book_id,$item->book_name);
                  ?>
                  <li class="product-item relative">
                     <a href="<?php echo $link?>">
                        <div class="left relative">
                           <?php if($item->book_sale > 0){?>
                           <div class="sale absolute">
                              <?php echo '-'.$item->book_sale.'%'?>
                           </div>
                           <?php }?>
                           <img alt="<?php echo $item->book_name?>" src="<?php echo Yii::app()->request->baseUrl?>/uploads/pictures/product/thumb_<?php echo $item->book_image?>" />
                        </div>
                        <div class="info">
                           <h3 class="font-14"><?php echo $item->book_name?></h3>
                           <p class="num-page">Số trang: <?php echo Str::formatNumber($item->book_num_page)?></p>
                           <?php 
                              $pub_name = isset($item->getRelated('publisher')->pub_name) ? $item->getRelated('publisher')->pub_name : 'Đang cập nhật';
                           ?>
                           <p class="publisher">Nhà xuất bản: <?php echo $pub_name?></p>
                           <?php 
                              $new_price = $item->book_price  - round($item->book_price * ($item->book_sale/100),0);
                           ?>
                           <p class="price"><?php echo Str::formatNumber($new_price)?> đ</p>
                           <?php if($item->book_sale > 0){?>
                           <p class="old-price"><?php echo Str::formatNumber($item->book_price)?> đ</p>
                           <?php }?>
                        </div>
                     </a>
                     <div class="option absolute">
                        <p class="btn btn-info add-to-cart" onclick="adToCart(<?php echo $item->book_id?>)">Thêm vào giỏ hàng</p>
                     </div>
                  </li>
               <?php }?>
         </ul>
      </div>
   </div>
<?php }?>
<?php if(count($list_sale_product) > 0){?>
   <div class="new-box">
      <h3 class="title">Sách khuyến mại</h3>
      <div class="woocommerce">
         <ul class="list-products">
            <?php
               foreach($list_sale_product as $item){
                  $link = $model->linkDetail($item->book_id,$item->book_name);
                  ?>
                  <li class="product-item relative">
                     <a href="<?php echo $link?>">
                        <div class="left relative">
                           <?php if($item->book_sale > 0){?>
                           <div class="sale absolute">
                              <?php echo '-'.$item->book_sale.'%'?>
                           </div>
                           <?php }?>
                           <img alt="<?php echo $item->book_name?>" src="<?php echo Yii::app()->request->baseUrl?>/uploads/pictures/product/thumb_<?php echo $item->book_image?>" />
                        </div>
                        <div class="info">
                           <h3 class="font-14"><?php echo $item->book_name?></h3>
                           <p class="num-page">Số trang: <?php echo Str::formatNumber($item->book_num_page)?></p>
                           <?php 
                              $pub_name = isset($item->getRelated('publisher')->pub_name) ? $item->getRelated('publisher')->pub_name : 'Đang cập nhật';
                           ?>
                           <p class="publisher">Nhà xuất bản: <?php echo $pub_name?></p>
                           <?php 
                              $new_price = $item->book_price  - round($item->book_price * ($item->book_sale/100),0);
                           ?>
                           <p class="price"><?php echo Str::formatNumber($new_price)?> đ</p>
                           <?php if($item->book_sale > 0){?>
                           <p class="old-price"><?php echo Str::formatNumber($item->book_price)?> đ</p>
                           <?php }?>
                        </div>
                     </a>
                     <div class="option absolute">
                        <p class="btn btn-info add-to-cart" onclick="adToCart(<?php echo $item->book_id?>)">Thêm vào giỏ hàng</p>
                     </div>
                  </li>
               <?php }?>
         </ul>
      </div>
   </div>
<?php }?>
</div>
<div class="right-content">
   <?php $this->renderPartial('//layouts/includes/box-news');?>
   <div class="fb-like-fp">
      <?php $this->renderPartial('//layouts/includes/box-like-fb');?>
   </div>
</div>
<script type="text/javascript">
	$(function() {
		$('#da-slider').cslider({
		 autoplay:true,
		});
	});
</script>